<template>
  <div>
    <div class="header-abs" v-show="showABS">
      <router-link to="/">
        <div class="iconfont header-back">&#xe68a;</div>
      </router-link>
    </div>
    <div class="header-fixed" v-show="!showABS" :style="opacityStyle">
      <router-link to="/">
        <div class="iconfont header-back">&#xe68a;</div>
      </router-link>
      景点详情
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  props: [],
  data() {
    return {
      showABS: true,
      opacityStyle: {
        opacity: 0,
      },
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    headerscroll() {
      console.log(document.documentElement.scrollTop);
      const top = document.documentElement.scrollTop;
      if (top > 1) {
        let opacity = top / 207;
        opacity = opacity > 1 ? 1 : opacity;
        this.opacityStyle = { opacity };
        this.showABS = false;
      } else {
        this.showABS = true;
      }
    },
  },
  activated() {
    window.addEventListener("scroll", this.headerscroll);
  },
};
</script>

<style lang='stylus' scoped>
.header-abs {
  position: absolute;
  left: 0.2rem;
  top: 0.2rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 0.4rem;

  .header-back {
    font-size: 0.5rem;
    text-align: center;
    line-height: 0.8rem;
  }
}

.header-fixed {
  text-align: center;
  line-height: 0.7rem;
  width: 100%;
  top: 0;
  position: fixed;
  height: 0.7rem;
  background: #00bcd4;
  color: #fff;

  .header-back {
    position: absolute;
    left: 0.3rem;
  }
}
</style>
